package com.hc.jdbc.base;

import com.hc.jdbc.Dao.UserDao;
import com.hc.jdbc.entity.User;

import java.sql.*;
import java.util.Scanner;

/**
 * 登录验证案例：预编译版本
 **/
public class Login3 {
    public static void main(String[] args) throws Exception {
        //1.键盘输入：
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入账号：");
        String account = scanner.nextLine();
        System.out.println("请输入密码：");
        String password = scanner.nextLine();

        UserDao userDao = new UserDao();
        User user = userDao.getUser(account, password);
        if (user != null) {
            System.out.println("登录成功，欢迎您，" + user.getNickname());
        }else {
            System.out.println("登录失败");
        }
    }
}
